package net.siufung.security.api.properties;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * @author 陈建峰
 * @since 2022/3/17 10:22 下午
 */
@Data
@ConfigurationProperties(prefix = SecurityProperties.SECURITY_PREFIX)
public class SecurityProperties {

    public static final String SECURITY_PREFIX = "siufung.security";

    /**
     * 不拦截
     */
    private AccessIgnore ignore;

    /**
     * 加密设置
     */
    private AccessEncrypt encrypt;


    public static class AccessIgnore implements Serializable {

        private static final long serialVersionUID = 1954552295512283293L;
        /**
         * 不拦截Urls
         */
        @Getter
        @Setter
        private List<String> urls = new ArrayList<>();

    }

    public static class AccessEncrypt implements Serializable {

        private static final long serialVersionUID = -1284955901315779584L;
        /**
         * 登录密码
         */
        @Getter
        @Setter
        private boolean password;

        /**
         * 登录密码加密方式
         */
        @Getter
        @Setter
        private String passwordType = AccessPasswordType.MD5.name().toLowerCase(Locale.ROOT);

        /**
         * 登录密码加密方式
         */
        @Getter
        @Setter
        private String passwordKey = "";

        /**
         * 登录密码类型
         */
        public enum AccessPasswordType {

            /**
             * MD5
             */
            MD5,
            /**
             * AES
             */
            AES
        }
    }

}
